package com.cedric.yixianpai.game.cards.Sects.swordCards.a_LianQi;

import com.cedric.yixianpai.game.Constants.Period;
import com.cedric.yixianpai.game.Status.DuelStatus;
import com.cedric.yixianpai.game.interfaces.SwordCard;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class FeiYaJian extends SwordCard {
    public FeiYaJian(@Value("1") int lvl) {
        super("飞牙剑");
        this.setLevel(lvl);
        this.setPeriod(Period.LIANQI);
        this.setDescription("8/11/14攻 击伤：返还剑意");

        this.setSpiritNeed(1);
        this.setReturnIntent(true);
        if (1 == lvl) {
            this.setDamage(8);
        } else if (2 == lvl) {
            this.setDamage(11);
        } else if (3 == lvl) {
            this.setDamage(14);
        } else {
            throw new RuntimeException("错误的卡牌等级！");
        }
    }

    /**
     * 生效卡牌
     * @param Sta1 p1Status
     * @param Sta2 p2Status
     * @return 是否生效
     */
    @Override
    public boolean effect(DuelStatus Sta1, DuelStatus Sta2) {
        if (Sta1.spiritEnough(this.getSpiritNeed())){
            if(0==Sta1.attack(Sta2, this.getDamage()))
            {
                Sta1.getPlayerBuff().setSwordIntent(0);
            }
            return true;
        } else {//灵气不足暂停回合
            return false;
        }
    }
}
